<template>
  <div>
    <div
         class="handle-box">
      <span style="padding:10px 10px 10px 0;">当前展会：</span>
      <el-select v-model="exhibitionId"
                 placeholder="选择展会"
                 @change="exhibitionSelect"
                 style="width: auto;display: inline-block;">
        <el-option v-for="item in exhibitionList"
                   :key="item.id"
                   :label="item.title"
                   :value="item.id">
        </el-option>
      </el-select>
    </div>
  </div>
</template>

<script>
import api from '@/api/index';
export default {
  props: ['setExhibition'],
  name: "exhibitionTmp",
  data () {
    return {
      exhibitionList: [],
      exhibitionId: ''
    }
  },
  created () {
    this.getUserExhib();
  },
  methods: {
    //获取获取当前管理员展会列表
    getUserExhib () {
      this.$http.post(api.GET_USER_EX_HIB, {})
        .then((res) => {
          console.log('展会列表', res)
          if (res.code == 1) {
            if (res.data && res.data.length > 0) {
              this.exhibitionList = res.data;
              this.exhibitionId=res.data[0].id;
              this.exhibitionSelect(res.data[0].id);
            }
          }else{
            if(res.msg==='not_gl'){
              this.getUserExhib1()
            }
          }
        })
    },
    getUserExhib1 () {
      this.$http.post(api.GET_USEREXHIB_CZY, {uid:JSON.parse(localStorage.getItem('userInfo')).id})
              .then((res) => {
                console.log('展会列表22222222222', res)
                if (res.code == 1) {
                  if (res.data && res.data.length > 0) {
                    this.exhibitionList = res.data;
                    this.exhibitionId=res.data[0].id;
                    this.exhibitionSelect(res.data[0].id);
                  }
                }else{

                }
              })
    },
    exhibitionSelect (e) {
      this.setExhibition(e)
    }
  }
}
</script>

<style scoped>
.handle-box {
    padding: 0 10px 0 0;
    margin-bottom: 20px;
}
</style>